package ai.connectfour.gui;

import java.awt.Graphics;
import java.awt.image.BufferedImage;

import javax.swing.JPanel;

import ai.connectfour.Config;
import ai.connectfour.entities.CellState;

public class GameFieldImagePanel extends JPanel {
	private static final long serialVersionUID = -6256940115476569883L;
	private int row;
	private int col;
	private BufferedImage crossImage;
	private BufferedImage circleImage;
	private CellState currentState;

	public GameFieldImagePanel(int row, int col, BufferedImage crossImage, BufferedImage circleImage) {
		super();
		this.row = row;
		this.col = col;
		this.crossImage = crossImage;
		this.circleImage = circleImage;
		currentState = CellState.EMPTY;
	}
	
	@Override 
	public void paintComponent(Graphics g) {
         super.paintComponent(g);
         g.drawRect(0, 0, Config.DIMENSION_ROWS*25, Config.DIMENSION_COLS*25);
         if(currentState == CellState.RED){
             g.drawImage(crossImage, 15, 15, Config.DIMENSION_ROWS*10, Config.DIMENSION_COLS*10, null); 
         }
         else if(currentState == CellState.YELLOW){
             g.drawImage(circleImage, 15, 15, Config.DIMENSION_ROWS*10, Config.DIMENSION_COLS*10, null); 
         }
    }
	
	public int getRow() {
		return row;
	}

	public int getCol() {
		return col;
	}

	public CellState getCurrentState() {
		return currentState;
	}

	public void setCurrentState(CellState currentState) {
		this.currentState = currentState;
	}
}
